package com.abc.example.entity;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

import javax.persistence.Column;
import com.fasterxml.jackson.annotation.JsonFormat;

import io.gitee.shengzheng1999.esbcommon.common.tree.ITreeNodeData;
import io.gitee.shengzheng1999.esbcommon.common.utils.LogUtil;

import lombok.Data;

/**
 * @className	: Orgnization
 * @description	: 组织机构对象实体类
 * @summary		: 对应数据表exa_orgnizations
 * @history		:
 * ------------------------------------------------------------------------------
 * date			version		modifier		remarks
 * ------------------------------------------------------------------------------
 * 2024/01/14	1.0.0		sheng.zheng		初版
 *
 */
@Data
public class Orgnization implements Serializable,ITreeNodeData{
    private static final long serialVersionUID = 1L;

	// 组织ID
	@Column(name = "org_id")
	private Integer orgId = 0;

	// 组织机构编号
	@Column(name = "org_code")
	private String orgCode = "";

	// 组织机构名称
	@Column(name = "org_name")
	private String orgName = "";

	// 组织机构全称
	@Column(name = "org_fullname")
	private String orgFullname = "";

	// 机构类型，1-本公司，2-客户公司，其它待扩展
	@Column(name = "org_type")
	private Byte orgType = 0;

	// 组织机构分类，保留
	@Column(name = "org_category")
	private Byte orgCategory = 0;

	// 负责人名称
	@Column(name = "leader")
	private String leader = "";

	// 联系人
	@Column(name = "contacts")
	private String contacts = "";

	// 联系电话
	@Column(name = "phone_number")
	private String phoneNumber = "";

	// Email
	@Column(name = "email")
	private String email = "";

	// 地址
	@Column(name = "address")
	private String address = "";

	// 邮编
	@Column(name = "zipcode")
	private String zipcode = "";

	// 行政区，省、市、区县名称
	@Column(name = "district")
	private String district = "";

	// 行政级别，1-国家级、2-副国级、3-省部级、4、副省级、5-市级、6、副市级、7-区县、8-副县级、9-街道乡镇级
	@Column(name = "district_level")
	private Byte districtLevel = 5;

	// 父组织ID
	@Column(name = "parent_id")
	private Integer parentId = 0;

	// 经度
	@Column(name = "lon")
	private Double lon = null;

	// 纬度
	@Column(name = "lat")
	private Double lat = null;

	// 备注
	@Column(name = "remark")
	private String remark = "";

	// 操作人账号
	@Column(name = "operator_name")
	private String operatorName = "";

	// 记录删除标记，0-正常、1-已删除
	@Column(name = "delete_flag")
	private Byte deleteFlag = 0;

	// 创建时间
	@Column(name = "create_time")
	@JsonFormat(shape= JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
	private LocalDateTime createTime = null;

	// 更新时间
	@Column(name = "update_time")
	@JsonFormat(shape= JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
	private LocalDateTime updateTime = null;

	// 父组织机构名称
    @Column(name = "parent_org_name")  
	private String parentOrgName = "";

	// 父组织机构全称
    @Column(name = "parent_org_fullname")  
	private String parentOrgFullname = "";


    // 获取对象key
    public Integer getObjKey(){
        return orgId;
    }
	// ================ 接口重载 ======================
	
	// 获取节点ID
	@Override
	public int getNodeId() {
		return orgId;
	}

	// 获取节点名称
	@Override
	public String getNodeName() {
		return 


        orgName;
	}
			
	// 获取父节点ID
	@Override
	public int getParentId() {
		return 0;
	}
	
	// 对象克隆
	@Override
	public Object clone(){
		Orgnization obj = null;
        try{
        	obj = (Orgnization)super.clone();
        }catch(CloneNotSupportedException e){
        	LogUtil.error(e);
        }

        return obj;
    }	
	
    // 比较对象是否相同
	public boolean equals(Orgnization anObject) {
		if (this == anObject) {
			return true;
		}else {
			return false;
		}				
	}
	
    // 获取对象的哈希码
    @Override
	public int hashCode() {
		return super.hashCode();
	}	
	
    // 格式化输出
	@Override
	public String toString() {
        String sRet = "";
        String ldtPattern = "yyyy-MM-dd HH:mm:ss";           
        DateTimeFormatter df = null;
        sRet += "{";
        sRet += "\"orgId\":" + orgId + ",";
        sRet += "\"orgCode\":\"" + orgCode + "\"" + ",";
        sRet += "\"orgName\":\"" + orgName + "\"" + ",";
        sRet += "\"orgFullname\":\"" + orgFullname + "\"" + ",";
        sRet += "\"orgType\":" + orgType + ",";
        sRet += "\"orgCategory\":" + orgCategory + ",";
        sRet += "\"leader\":\"" + leader + "\"" + ",";
        sRet += "\"contacts\":\"" + contacts + "\"" + ",";
        sRet += "\"phoneNumber\":\"" + phoneNumber + "\"" + ",";
        sRet += "\"email\":\"" + email + "\"" + ",";
        sRet += "\"address\":\"" + address + "\"" + ",";
        sRet += "\"zipcode\":\"" + zipcode + "\"" + ",";
        sRet += "\"district\":\"" + district + "\"" + ",";
        sRet += "\"districtLevel\":" + districtLevel + ",";
        sRet += "\"parentId\":" + parentId + ",";
        sRet += "\"lon\":" + lon + ",";
        sRet += "\"lat\":" + lat + ",";
        sRet += "\"remark\":\"" + remark + "\"" + ",";
        sRet += "\"operatorName\":\"" + operatorName + "\"" + ",";
        sRet += "\"deleteFlag\":" + deleteFlag + ",";
        if (createTime != null){
            df = DateTimeFormatter.ofPattern(ldtPattern);
            String formatStr = createTime.format(df);
            sRet += "\"createTime\":\"" + formatStr + "\"" + ",";
        }else{
            sRet += "\"createTime\":\"" + "null" + "\"" + ",";
        }
        if (updateTime != null){
            df = DateTimeFormatter.ofPattern(ldtPattern);
            String formatStr = updateTime.format(df);
            sRet += "\"updateTime\":\"" + formatStr + "\"" + ",";
        }else{
            sRet += "\"updateTime\":\"" + "null" + "\"" + ",";
        }
        sRet += "\"parentOrgName\":\"" + parentOrgName + "\"" + ",";
        sRet += "\"parentOrgFullname\":\"" + parentOrgFullname + "\"";
		sRet += "}";
        
        return sRet;
	}    
}